package com.fcgzs.springboot;

import com.baomidou.mybatisplus.annotation.DbType;

import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.config.*;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;

/*public class PlusGenerator {
    public static void main(String[] args) {

        //核心代码生成器工具类
        AutoGenerator generator = new AutoGenerator();

        //全局配置(作者 生成位置...)GlobalConfig
        GlobalConfig globalConfig = new GlobalConfig(); //注意是baomidou类型
        globalConfig.setOutputDir("E:\\Works\\Path_Files\\Idea\\0913\\offcnpe_parent\\offcnpe_util\\src\\main\\java");
        globalConfig.setAuthor("wjd");
        generator.setGlobalConfig(globalConfig);

        //数据源对象 DataSourceConfig
        DataSourceConfig dataSourceConfig = new DataSourceConfig();
        dataSourceConfig.setUrl("jdbc:mysql:///aijiankangpe");
        dataSourceConfig.setDriverName("com.mysql.jdbc.Driver");
        dataSourceConfig.setUsername("root");
        dataSourceConfig.setPassword("root");
        dataSourceConfig.setDbType(DbType.MYSQL);
        generator.setDataSource(dataSourceConfig);

        //生成代码的包名配置 PackageConfig
        PackageConfig packageConfig = new PackageConfig();
        packageConfig.setParent("com.fcgzs.springboot");
        packageConfig.setController("controller");
        packageConfig.setEntity("pojo");
        //packageConfig.setService("service");
        packageConfig.setMapper("mapper");
        generator.setPackageInfo(packageConfig);


        //指定我们生成的代码的模板
        TemplateConfig templateConfig = new TemplateConfig();
        //不需要生成代码内容 我们我们可以在这里设定为null
        templateConfig.setService(null);
        templateConfig.setServiceImpl(null);
        generator.setTemplate(templateConfig);

        //策略的配置对象 StrategyConfig(指定模板 那些内容生成那些内容不生成,_驼峰标识处理  声明表  lombok)
        StrategyConfig strategyConfig = new StrategyConfig();
        strategyConfig.setNaming(NamingStrategy.underline_to_camel); //表名中_生成实体类采用驼峰
        strategyConfig.setColumnNaming(NamingStrategy.underline_to_camel);//表中字段_生成实体类采用驼峰
        strategyConfig.setEntityLombokModel(true); //lombok注解
        strategyConfig.setRestControllerStyle(true); //生成controller支持restful编码风格

        String tableNames="t_checkgroup,t_checkgroup_checkitem,t_checkitem,t_member,t_menu," +
                "t_order,t_ordersetting," +
                "t_permission,t_role,t_role_menu," +
                "t_role_permission,t_setmeal,t_setmeal_checkgroup,t_user,t_user_role";
        strategyConfig.setInclude(tableNames.split(",")); //多个表之间使,号分割
        strategyConfig.setControllerMappingHyphenStyle(true);//生成的controller添加统一映射头
        strategyConfig.setTablePrefix("t_");
        generator.setStrategy(strategyConfig);

        //生成代码
        generator.execute();
    }
}*/
